﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TerisInstance
{
    public Teris Teris;
    public Slot.State[] Contents;
    private static int treasureNum = 1, boxNum = 3, enemy1Num = 1, enemy2Num = 17;

    public TerisInstance(Teris teris, int option = 1) {
        Teris = teris;
        Contents = new Slot.State[Teris.SquareCount];
        if(Teris.SquareCount == 36) {
            for(int i = 0; i < Teris.SquareCount; i++) {
                Contents[i] = Slot.State.empty;
            }
            Contents[19] = Slot.State.boss1;
            Contents[18] = Slot.State.none;
            Contents[20] = Slot.State.none;
            Contents[12] = Slot.State.none;
            Contents[13] = Slot.State.none;
            Contents[14] = Slot.State.none;
            Contents[24] = Slot.State.none;
            Contents[25] = Slot.State.none;
            Contents[26] = Slot.State.none;
        }
        else {
            for(int i = 0; i < Teris.SquareCount; i++) {
                int t = Random.Range(0, 36);
                Contents[i] = Slot.State.empty;
                if(treasureNum <= 0) {
                    Contents[i] = Slot.State.treasure;
                    treasureNum = Random.Range(7, 11 - option);
                }
                else if(boxNum <= 0) {
                    Contents[i] = Slot.State.box;
                    boxNum = Random.Range(7, 11 - option);
                }
                if(option == 1) {
                    if(enemy1Num <= 0) {
                        Contents[i] = Slot.State.enemy;
                        enemy1Num = Random.Range(32, 41);
                    }
                    else if(enemy2Num <= 0) {
                        Contents[i] = Slot.State.enemy2;
                        enemy2Num = Random.Range(32, 41);
                    }
                    enemy1Num--;
                    enemy2Num--;
                }
                treasureNum--;
                boxNum--;
            }
        }
    }
}
